﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

namespace MVVMFramework.ViewModel
{
    /// <summary>
    /// This class is for additional arguments of Property Changed event
    /// </summary>
    public static class PropertyChangedEventArgsExtensions
    {
        /// <summary>
        /// Indicates whether property is changed.
        /// </summary>
        /// <param name="args">The <see cref="System.ComponentModel.PropertyChangedEventArgs"/> instance containing the event data.</param>
        /// <param name="property">The property.</param>
        public static bool IsPropertyChanged(this PropertyChangedEventArgs args, Expression<Func<object>> property)
        {
            if (property == null)
                throw new ArgumentNullException("property");

            string propertyName = NotifyPropertyChangedBase.GetPropertyName(property);
            if (args.PropertyName.Equals(propertyName))
                return true;

            return false;
        }
    }
}
